#include <iostream>
#include <string>
#include <vector>
using namespace std;

#define MAXL 305
#define MIN(a,b) ((a)<(b)?(a):(b))

int W, L;
string msg;
vector<string> dict;

int DP[MAXL];

int match(string d, int mi) {
    int lend = d.length();
    int i, j = 0;
    for (i=mi; i<L && j<lend; i++) {
        if (msg[i] == d[j]) {
            j++;
        }
    }
    if (j < lend)
        return -1;
    //return i - mi - lend;
    return i;
}

int solve() {
    for (int i=L-1; i>=0; i--) {
        DP[i] = DP[i+1] + 1;
        for (int j=0; j<W; j++) {
            if (dict[j][0] == msg[i]) {
                int r = match(dict[j], i);
                if (r >= 0) {
                    int skip = r - i - dict[j].length();
                    DP[i] = MIN(DP[i], DP[r]+skip);
                }
            }
        }
    }
    return DP[0];
}

int main()
{
    cin >> W >> L;
    cin >> msg;
    for (int i=0; i<W; i++) {
        string s;
        cin >> s;
        dict.push_back(s);
    }
    int ans = solve();
    cout << ans << endl;
    return 0;
}
